home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ansi / hercules.zip / HERCULES.PRG < prev    next >
Text File  |  1986-09-06  |  5KB  |  121 lines

  1.               Hercules Monochrome Graphics Card Programming
  2.               ---------------------------------------------
  3.  
  4.                              provided by
  5.  
  6.                 Robert Morse  MLO5-2/B6  LEWS2::MORSE
  7.  
  8. The board configuration is controlled by the write-only control register
  9. at port 03BF.  All bits are set to zero upon power-up, which limits
  10. the board to text mode (it will pass IBM monochrome display adapter
  11. diagnostics only while all bits are zero).
  12.  
  13. Bit     Description
  14. ---     -----------
  15.  0      0=disable setting of graphics mode; 1=allow graphics mode.
  16.  1      0=disable page one (allows coexistence with a color graphics
  17.                board); 1=enable page one (required to run Lotus 1-2-3).
  18.  2..7     (not used)
  19.  
  20.  
  21.  
  22. Modes are controlled by the write-only control register at port 03B8. All
  23. bits are set to zero upon power-up. 
  24.  
  25. Bit     Description
  26. ---     -----------
  27.  0        (not used)
  28.  1      0=text; 1=graphics.
  29.  2        (not used)
  30.  3      0=blank screen; 1=activate screen.
  31.  4        (not used)
  32.  5      0=disable text blink; 1=enable text blink.
  33.  6        (not used)
  34.  7      0=page zero at B0000h; 1=page one at B8000h.
  35.  
  36.  
  37.  
  38. Table of 6845 values (all values in hexadecimal): 
  39.  
  40. Register                        Text    Graphics
  41. -------------------------       ----    --------
  42.  0  Total chars/row -1           61        35    
  43.  1  Visible chars/row            50        2D
  44.  2  Hsync position               52        2E
  45.  3  Hsync width                  0F        07
  46.  4  Total rows -1                19        5B
  47.  5  Additional scan lines        06        02
  48.  6  Visible rows                 19        57
  49.  7  Vsync position               19        57
  50.  8  Interlace control            02        02
  51.  9  Lines/row -1                 0D        03
  52.  A  Top cursor scan              0B        00
  53.  B  Bottom cursor scan           0C        00
  54.  C  Display origin               00        00
  55.  D  Display origin               00        00
  56.  
  57. In text mode, each character time is 0.5625 microseconds and a character is
  58. 9 dots wide and 14 dots high.  The controller is programmed for 25
  59. displayed rows of 14 scan lines each.  There are 350 visible scan lines and
  60. 370 total scan lines. 
  61.  
  62.  
  63. In graphics mode, each character time is 1.000 microseconds and a character
  64. is 16 dots wide and 4 dots high.  The controller is programmed for 87
  65. displayed rows of 4 scan lines each.  There are 348 visible scan lines and
  66. 370 total scan lines.  Each row has 45 displayed characters of 16 bits,
  67. giving 720 dots/row.
  68.  
  69.  
  70. <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  71.                       Note on Addressing the Screen
  72.                       -----------------------------
  73.  
  74. The preceding paragraph gives a hint about pixel addresses in graphics 
  75. mode.  I looked through the HERCBIOS sources and then wrote a program
  76. (HERCDEMO.ASM) to help me understand this.  Here's how screen addressing
  77. works:
  78.       
  79.       o Although you might think of graphics mode as pure bits, the 6845
  80.         chip always thinks in term of characters.  When you switch to
  81.         graphics mode, the characters are 16 bits wide by 4 bits high.
  82.         Thus, in graphics mode the screen has 87 rows of "characters"
  83.         and each row is 45 characters wide, for 720x348 pixels.
  84.       
  85.       o For a reason unknown to me (probably speed of memory access),
  86.         each of the four scan lines in a graphics character is stored in
  87.         a different "bank" or 2000h section of the screen buffer.  All
  88.         87 scan line 0s are stored from 0-2000h, all scan line 1s from
  89.         2000h-4000h, all scan line 2s from 4000h-6000h, and all scan
  90.         line 3s from 6000h-8000h.
  91.       
  92.       o Within a bank of memory (representing one set of scan lines),
  93.         each row is 45 words or 90 bytes wide.  Rows follow each other
  94.         with no intervening space. So, assuming row numbers from 0 to
  95.         86, the 5th graphics character in row 40 is composed of four
  96.         scan lines, each 16 bits wide, located at the following memory
  97.         addresses (offsets from the beginning of the screen buffer):
  98.                 40*90 = 3600    (offset in any bank to row 40)
  99.                 4*2=8           (5th graphics char = (n-1)*2 bytes/char)
  100.                 Scan line 0:    locations 3608,3609
  101.                 Scan line 1:    2000h (8192) + 3608,9 = 11800,11801
  102.                 Scan line 3:    4000h (16384) + 3608,9 = 19992,19993
  103.                 Scan line 4:    6000h (24576) + 3608,9 = 28184,28185
  104.       
  105.       o Computing a pixel location is a little harder, but still fairly
  106.         straightforward.  Say you want to address the bit at 300,300
  107.         with a point of origin at the upper left.  300 scan lines down
  108.         from the top is 300/4 = 75 (no remainder), which is scan line 0
  109.         of row 75.  300 bits into the line is 300/8 = 37 remainder 4.
  110.         The bit you want is in bank 0 (0-2000h) since it is scan line 0,
  111.         offset by 75*90 =6750 for the row, plus 37 for the byte within
  112.         the row, or byte offset 6787 from the beginning of that page in
  113.         screen memory.  Within that byte, you want to set/reset bit 4.
  114.       
  115.       
  116. Well, that should cover it.  If you should discover that I got any of
  117. this wrong, send me mail.
  118.       
  119. -Reid Brown
  120. DECWET::BROWN
  121.